{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'paddle'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-6-9d4e8096d1d0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mpaddle\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mpaddle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnn\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mLinear\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mpaddle\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunctional\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mF\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'paddle'"
     ]
    }
   ],
   "source": [
    "import paddle\n",
    "from paddle.nn import Linear\n",
    "import paddle.nn.functional as F\n",
    "import os\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as olt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_dataset=paddle.vision.datasets.MNIST(mode='train')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_data0=np.array(train_dataset[0][0])\n",
    "train_label_0=np.array(train_dataset[0][1])\n",
    "import matplotlib.pyplot as plt\n",
    "plt.figure(\"lmage\")\n",
    "plt.figure(figsize=(2,2))\n",
    "plt.imshow(train_data0, cmap=plt.cm.binary)\n",
    "plt.axis('on')\n",
    "plt.title('image')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"图像数据形状和对应数据为:\" ,train_data0.shape)\n",
    "print(\"图像标签形状和对应数据为:\" ,train_label_0.shape,train_label_0)\n",
    "print(\"\\n输出第一个批次的第一个图像, 对应标签数字为{}\" .format(train_label_0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "class MNST(paddle.nn.Layer):\n",
    "    def__init__(self):\n",
    "        super(MNIST,self).__init__()\n",
    "        self.fc1 = Linear(in_features=784, out_features=100)\n",
    "        self.fc2 = Linear(in_features=100,out_features=100)\n",
    "        self.fc3 = Linear(in_features=100, out_features=10)\n",
    "        def forward(self,inputs):\n",
    "            outputs1 = self.fc1(inputs)\n",
    "            outputs1 = F.ReLU(outputs1)\n",
    "            outputs2 = self.fc2(outputs1)\n",
    "            outputs2 = F.ReLU(outputs2)\n",
    "            outputs_final = self.fc3(outputs2)\n",
    "            outputs_final = F.softmax(outputs_final)\n",
    "            renturn outputs_final"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def norm_img(img)\n",
    "assert len(img.shape)==3\n",
    "batch_size,img_h,img_w=img.shape[0],img.shape[1],img.shape[2]\n",
    "img =img/255\n",
    "img = paddle.reshape(img,[batch_size,img_h*img_w])\n",
    "return img"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
